home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / faq / comp / linux / howto / printing / part2 < prev   
Encoding:
Internet Message Format  |  1994-03-21  |  59.4 KB

  1. Path: bloom-beacon.mit.edu!hookup!swrinde!emory!news-feed-2.peachnet.edu!concert!bigblue.oit.unc.edu!sunSITE!mdw
  2. From: gtaylor@cs.tufts.edu (Grant Taylor)
  3. Newsgroups: comp.os.linux.announce,comp.os.linux.admin,comp.answers,news.answers
  4. Subject: Linux Printing HOWTO (Part 2/2)
  5. Followup-To: poster
  6. Date: 16 Mar 1994 05:54:36 GMT
  7. Organization: The University of North Carolina at Chapel Hill
  8. Lines: 1304
  9. Approved: linux-announce@tc.cornell.edu (Matt Welsh)
  10. Message-ID: <2m66us$onn@bigblue.oit.unc.edu>
  11. NNTP-Posting-Host: calzone.oit.unc.edu
  12. Summary: HOWTO on printing under Linux
  13. Keywords: Linux, printing, lpr
  14. Originator: mdw@sunSITE
  15. Xref: bloom-beacon.mit.edu comp.os.linux.announce:1959 comp.os.linux.admin:5621 comp.answers:4190 news.answers:16459
  16.  
  17. Archive-name: linux/howto/printing/part2
  18. Last-Modified: 22 Feb 94
  19.  
  20. [This is part 2/2 of the Printing HOWTO]
  21.  
  22. 3.2 What lpr and lpd do
  23. =======================
  24.  
  25.    Most Un*x systems use `lpd' (or the System V variant `lp'), the line
  26. printer daemon, and friends to spool print jobs and run them through
  27. all needed filters.  While line printers are certainly on their way
  28. out, spooling print jobs and running them through filters is definitely
  29. a convenient thing.  Thus lpr.  (subliminal note: *PLEASE* find and
  30. read the `lpr', `lpd', `printcap', `lpc', `lpq', and `lprm' man pages.
  31. They are in the source dist of the net-2, if you haven't got them.)
  32.  
  33. 3.3 Getting hold of lpd
  34. =======================
  35.  
  36.    Lpd and family are available in several places.  The new Linux net-2
  37. package contains a working BSD-style lpd (although it has a couple of
  38. bugs and Makefile installs the binaries with the wrong permissions).  I
  39. now use this one with my stock 0.99pl14 kernel after following the
  40. directions in Matt Welsh's Net-2 HOWTO to get my NET-2 going (you only
  41. need loopback). Most people (and this document) consider this to be
  42. *the* Linux lpd package. A slightly debugged version incorporating
  43. patches from earlier releases of this HOWTO is also available in:
  44. `tsx-11.mit.edu:/pub/linux/packages/net/new-net-2/lpd-590p?.tar.gz'
  45.  
  46.    Some of the prepackaged Linux distributions have a very poor record
  47. with respect to having a working lpd packages so don't be shy of
  48. getting a new one if you seem to be having trouble.
  49.  
  50.    Fans of the SysV lp package should consider getting plp (however this
  51. HOWTO contains no information on that package)
  52.  
  53.    An lpd binary package which can be coaxed into working with the old
  54. net things (pre 0.99pl10 kernel) may still be around but you'll probably
  55. find it a bit shakey and you really should update your kernel.  Note a
  56. subtle difference between the two versions: the old one placed lock
  57. files and such in `/var/spool', while the net-2 version requires the
  58. directory `/var/spool/lpd' to exist for its lock file.
  59.  
  60.    You will need to edit `/etc/printcap' to configure lpd to use your
  61. printer. Setting up lpd to accept PostScript and print it is not very
  62. difficult; simply make a shell script filter. See Also: Writing lpd
  63. filters
  64.  
  65.    Setting up lpd correctly is definitely worth the trouble if you are
  66. going to do any printing at all.  Of course, if all you ever print is
  67. the occasional man page or instruction book, then you can probably get
  68. by without it (but even then it's nice).
  69.  
  70.    Ghostscript 2.6.x also comes with a complicated script and utilities
  71. to generate printcap entries and manage multiple types of queues for a
  72. printer.  I have not tested these, but I assume they can be made to
  73. work.  If you are in a large-scale environment with varied printing
  74. needs, these may be worth a look.
  75.  
  76. 3.4 Where Do The Files Go And What Should Their Permissions Be?
  77. ===============================================================
  78.  
  79.    There is quite a bit of variation between the various releases but
  80. I'll try where possible to offer solutions that are universally
  81. applicable. Start `lpd' in your `/etc/rc' or `/etc/rc.local' (usually
  82. in `/etc/rc.local' after you start `syslogd' (if you use `syslogd')).
  83.  
  84.    Set the group fields of the file permissons/ownership as follows:
  85.  
  86.      -rwxr-sr--   1 root     lp          37892 Nov 19 23:32 /etc/lpd
  87.      -rwxr-sr-x   1 root     lp          21508 Nov 19 23:32 /usr/bin/lpc
  88.      -rwsr-sr-x   1 root     lp          17412 Nov 19 23:32 /usr/bin/lpq
  89.      -rwxr-sr-x   1 root     lp          17412 Nov 19 23:32 /usr/bin/lpr
  90.      -rwxr-sr-x   1 root     lp          17412 Nov 19 23:32 /usr/bin/lprm
  91.      -rwxr-xr-x   1 root     lp           2816 May 10 13:37 /usr/bin/lptest
  92.      
  93.      ...and for each of the spool directories listed in the sd fields of
  94.      /etc/printcap...
  95.      
  96.      /var/spool/lpd:
  97.      total 5
  98.      drwxrwxr-x   2 root     lp           1024 May 18 23:00 .
  99.      drwxr-xr-x  11 root     root         1024 Feb 19 20:56 ..
  100.      -rw-rw-r--   1 root     lp              4 May 18 23:00 .seq
  101.      -rw-rw-r--   1 root     lp             18 May 18 23:00 lock
  102.      -rw-rw-r--   1 root     lp             25 May 18 23:00 status
  103.  
  104.    Note these 3 files are created by lpr and lpd so if you've never run
  105. these they will be absent. With some versions of the lpd package you
  106. had to touch them into being or they would be created with the wrong
  107. permissions but this bug seems to have been fixed.
  108.  
  109.    In older versions the group id was `daemon' not `lp'. There's also a
  110. named socket but `lpd' creates/deletes it as needed. Also you may find
  111. the uid is sometimes set to `daemon' or `lp' rather than `root' but
  112. this is of no consequence except on setuid binaries.
  113.  
  114.    These permissions are the most pedantic so don't be surprised if
  115. your system works with different permissions. On the other hand if lpd
  116. is not working for you and you have different permissions please try
  117. these before mailing us or posting to usenet. (This may sound obvious
  118. but you'd be amazed how much mail I've had from people with the
  119. permissions set wrong).
  120.  
  121.    People tell me that `lpr' must be setuid(root) but I've not seen
  122. evidence that this is really the case as long as the file permissions on
  123. the spool queues are right. Still as far as I know `lpr' is designed to
  124. be secure when installed setuid(root). This allows an alternative
  125. (sloppy) approach: just make `lpr' and `lprm' setuid(root) then you can
  126. almost forget the file permissions on the spool queues!
  127.  
  128.    You're free to choose different directories for the executables on
  129. your system (notably `lpc' is usually in `/etc' (or `/usr/sbin') even
  130. though it has commands that are useful to non-root). Of course since
  131. you are free to do this it implies the person who made up your
  132. distribution was also free to do so, so be carefull to make sure you
  133. delete old components when you install new ones.
  134.  
  135.    The master lpd lock file is fixed at compile time to be
  136. `/var/spool/lpd/lpd.lock' so you must have a `/var/spool/lpd directory'
  137. even if you choose not to keep your spool queue there. In the older
  138. binaries the lock file was `/usr/spool/lpd.lock' so this was not an
  139. issue.
  140.  
  141.    My advise is to keep your primary spool queue in `/usr/spool/lpd' and
  142. make `/var' a symlink to `usr' or keep it in `/var/spool/lpd' and make
  143. `/usr/spool' a symlink to `../var/spool'. This gives the greatest
  144. compatibility with the pathnames that are compiled into the various
  145. distributed binaries. Note that having a separate `/var' filesystem
  146. avoids the problem of your `/usr' filesystem filling up as a result of
  147. stuff in spool queues.
  148.  
  149.    The main configuration file is `/etc/printcap'. Network printing also
  150. uses `/etc/hosts.allow' and `/etc/hosts.lpd'.
  151.  
  152.    By now everyone should have libraries and binaries that look for
  153. config files in `/etc'. If you chose to keep your configs somewhere else
  154. (`/conf' or `/usr/etc' for example) then `/etc' must contain a symlink
  155. to the real file. If you still have a system which looks for files in
  156. `/usr/etc' or `/etc/inet' your system is way out of date and you should
  157. upgrade.
  158.  
  159. 3.5 lpd not working
  160. ===================
  161.  
  162.    If `ps ax' does not reveal a `lpd' then you daemon has died (or was
  163. never started) - usually a sign that it couldn't create its lockfile,
  164. or was unable to find `/etc/services'.  (This will happen if you tried
  165. to start it before all your filesystems were mounted).
  166.  
  167.    If `lpr' works only for root then you've probably got a permission
  168. problem.
  169.  
  170.    If you cant even `cat' files to the printer then you may be using
  171. the wrong device name for the printer in `/etc/printcap' See Also: Printer
  172. device names or you may need to fiddle with `tunelp'.  See Also: hardware
  173. and drivers.
  174.  
  175.    If you get "jobs queued, but cannot start daemon" or "lpc: connect:
  176. No such file or directory" while `lpd' is running then you are having
  177. trouble with the socket connection to `lpd'. "start" in the context of
  178. this error really means "wake". This problem has come and gone
  179. thoughout the history of Linux - I don't really understand this but it
  180. stems from an erroneous interaction between the networking stuff and
  181. "Unix domain" (non-network) sockets. Usually it has only shown up when
  182. the network is incorrectly configured. If you're not really on a
  183. network it is usually adequate just to have the following somewhere in
  184. your startup.
  185.  
  186.      ifconfig lo localhost
  187.      route add localhost
  188.  
  189.    You'll also need to have the `/etc/hosts' file. There's no need to
  190. run any daemons.
  191.  
  192.    There is second and much more understandable way to produce this
  193. error - use a mixture of components from different releases of lpd that
  194. use different names for the Unix domain socket (new stuff uses
  195. `/tmp/.printer', obsolete stuff `/dev/printer'). (For some time SLS was
  196. released this way).
  197.  
  198.    At the time of writing I am quite unable to reproduce this error - I
  199. am using my debugged version of the net-2 lpd compiled with gcc-2.4.5
  200. and libc-4.4.4 on kernel 0.99.14.
  201.  
  202. 3.6 Where Do I Get A Printcap For Printer Model xxxxx?
  203. ======================================================
  204.  
  205.    This question is essentially meaningless so please don't ask it on
  206. usenet See Also: The Semantics of /etc/printcap.
  207.  
  208. 3.7 The Semantics of `/etc/printcap'
  209. ====================================
  210.  
  211.    Given the similarity in appearance and name between `/etc/termcap'
  212. and `/etc/printcap' one could be forgiven for assuming that they
  213. contain analogous infomation. This is not the case. Whereas
  214. `/etc/termcap' contains informations about terminal *types* - (mostly
  215. escape seqences) printcap contains information about *specific*
  216. printers (like the directory that holds the spool queue, the device
  217. name of the printer and what room it's in). The information about a
  218. printer model's escape sequences and so on are held in the various
  219. "filters" which are programs called by `lpd' to drive the printer.
  220. `/etc/printcap' simply gives the locations of these filters.  For
  221. details RTFM(printcap). [Alternatively the net-HOWTO has a summary of
  222. some of the more important fields.]
  223.  
  224.    One last point - you should always specify `suppress header' `:sh:'
  225. unless you have a *text* (not PostScript) printer and want banners. On
  226. a text printer they are usually a waste of time and paper. On a
  227. PostScript printer they usually stop your printer working.  See Also:
  228. Burst/banner pages.
  229.  
  230. 3.8 The Syntax of `/etc/printcap'
  231. =================================
  232.  
  233.    Ideally RTFM(termcap) (yes, I said *termcap*) but since most people
  234. don't have TFM(termcap) here are the essentials.
  235.  
  236.    Lines starting with `#' are comments (as you might have guessed).
  237.  
  238.    For each printer usable from the `lpr' command on your system there
  239. is one logical line in the file. For the sake of readability each
  240. logical line may be spread over several physical lines by making the
  241. last character on all but the last physical line a backslash.
  242.  
  243.    Each logical line has the following format:
  244.  
  245.      NAME1|NAME2|NAME3:STRING_CAPABILITY=STRING:\
  246.             :NUMERIC_CAPABILITY#NUMBER:BOOLEAN_CAPABILITY:
  247.  
  248.    The leading spaces and colon on the second line are for readability
  249. only.
  250.  
  251.    A printer can have as many names as you like but conventionally the
  252. final name is used as a longhand description of the printer. (Still
  253. people are free to say `lpr -P "grotty teletype in room 213"' if that's
  254. the description you've given.) One of the names of your default printer
  255. must be `lp'.
  256.  
  257.    The list of capabilities can be as long as needed and the order is
  258. not significant. Each "capability" is denoted by a two character code.
  259. (The name "capability" comes form the file format's termcap heritage -
  260. parameter or attribute would be a more sensible terms.) [Note from Ross
  261. Biro: capabilities with 3 character names don't work properly which is
  262. why the serial port stuff in the old binaries failed.]  Capabilities
  263. having string value and have a `=' delimiter between the capability
  264. name and the value while those having a numeric value use a `#'
  265. (actually they can use either a `#' or an `='). Boolean "capabilities"
  266. are true if they appear in the list and false if they do not.
  267.  
  268.    Special characters in a string value can be expressed using
  269. backslash-escaped sequences as in C; in addition, `\E' stands for ESC.
  270. `^' is also a kind of escape character; `^' followed by CHAR stands for
  271. the control-equivalent of CHAR.  Thus, `^a' stands for the character
  272. control-a, just like `\001'. `\' and `^' themselves can be represented
  273. as `\\' and `\^' respectively. `\:' for `:' seems to work but the
  274. source code contains a warning that it can confuse the parser and
  275. `\072' is a better idea.
  276.  
  277.    Example:
  278.      lp|bam|Epson FX-80:lp=/dev/lp1:sd=/usr/spool/lp1:sh:mx#0:\
  279.              :df=/usr/local/lib/magic-filter/lp.df:\
  280.              :if=/usr/local/lib/magic-filter/lp.if:
  281.  
  282.    The printer's name is `lp' (this is the printer that `lpr' uses by
  283. default). It's also known as `bam' or `"Epson FX-80"'.
  284.  
  285.    The printer is on `/dev/lp1' (aka AT-bus LPT1:). I don't want a burst
  286. page. I don't want a file length limit. Files queued by `lpr -d' are
  287. passed through `/usr/local/lib/magic-filter/lp.df' and those queued by
  288. `lpr' through `/usr/local/lib/magic-filter/lp.lf'.
  289.  
  290.    See also the next section.
  291.  
  292. 3.9 An `/etc/printcap' gotcha
  293. =============================
  294.  
  295.    Two `/etc/printcap' files can look identical and yet one works and
  296. the other doesn't.
  297.  
  298.    See if `lpc stat' reports a printer called ` :'. The last character
  299. on a continued line must be a backslash. If there are whitespace
  300. characters after the backslash then it doesn't register the next line
  301. as a continuation.
  302.  
  303. 3.10 The Minimum /etc/printcap
  304. ==============================
  305.  
  306.    This is a silly question but it is frequently asked. The answer is
  307. `lp:sh' (that's 6 bytes including the required linefeed character on
  308. the end). To use this `/etc/printcap' you must make `/dev/lp' a symlink
  309. to your printer and create your spool queue directory as
  310. `/usr/spool/lpd'.  (You might think that if you wanted banner pages you
  311. could loose the `:sh' but the termcap syntax requires at least one
  312. capability per entry).
  313.  
  314. 3.11 How to prevent the `Staircase Effect'
  315. ==========================================
  316.  
  317.    Un*x terminates each line of a file with a linefeed but not a
  318. carriage return so taken literally a Un*x text file printed on an ASCII
  319. device will start each line below the end of the previous line.  Some
  320. printers can be set to treat "linefeed" as "carriage return, linefeed",
  321. others can't. If yours can then do simply do that. If the printer
  322. cannot be fixed create a shell script filter that reads:
  323.  
  324.      #!/bin/sh
  325.      if [ "$1" = -c ]; then
  326.        cat
  327.      else
  328.        sed -e s/$/^M/
  329.      fi
  330.      # the ``echo -ne'' assumes that /bin/sh is really bash
  331.      echo -ne \\f
  332.  
  333.    Where `^M' is a carriage return character not a `^' followed by a
  334. `M'.  To type `^M' in Emacs use the sequence `C-q C-m' and in vi use
  335. `C-v C-m'.  Conventionally this script is called `/usr/lib/lpf'. If you
  336. have more than one such script a better idea is to keep them in a
  337. subdirectory, say `/usr/lib/lpd/'. The test of `$1' allows the
  338. insertion of carriage returns to be switched off by `lpr -l'.
  339.  
  340.    Install this filter as the `if' filter by putting
  341. `:if=/usr/lib/lpf:' (or whatever) in your `/etc/printcap' entry for the
  342. printer.
  343.  
  344.    Alternatively your printer may have an escape sequence that will set
  345. the way it handles linefeed characters. A simple filter that uses an
  346. `echo -ne' command to send this sequence may be appropriate.
  347.  
  348.      #!/bin/sh
  349.      # Filter for HP printers to treat LF as CRLF
  350.      # the ``echo -ne'' assumes that /bin/sh is really bash
  351.      echo -ne \\033\&k2G
  352.      cat
  353.      echo -ne \\f
  354.  
  355. 3.12 Resetting the printer between each file printed
  356. ====================================================
  357.  
  358.    Either make your filters do it or define the `tr' "capability" in
  359. `/etc/printcap' to be your printer's font reset command. For details of
  360. the format of this string see the question on the format of printcap.
  361. This may not work if a printout crashes in the middle of an escape
  362. sequence - putting a lot of `^@' on the front may help but this
  363. probably won't be enough it you were printing raster graphics when the
  364. filter died.
  365.  
  366. 3.13 Preventing formfeed after each file printed
  367. ================================================
  368.  
  369.    If you don't have an `if' specified in `/etc/printcap' then `lpd'
  370. will automatically put a formfeed at the end of each file. If you're
  371. using a filter then it's up to the filter to decide if it wants to put
  372. a formfeed. To disable formfeed completely if you don't have an `if'
  373. put `:ff=:' in your `/etc/printcap'.  But please note this suppresses
  374. the formfeed that would usually be printed if a filter dies. If you
  375. want formfeeds after text printouts but not on printouts printed with
  376. `lpr -l' then create the following `if' filter:
  377.  
  378.      #!/bin/sh
  379.      # the ``echo -ne'' assumes that /bin/sh is really bash
  380.      cat
  381.      if [ "$1" != -c ]; then
  382.        echo -ne \\f
  383.      fi
  384.  
  385.    If you want a formfeed after `lpr -l' to be optional you can misuse
  386. the `-i' switch to suppress the formfeed with the following trick (after
  387. all `lpr -i -l' would usually not be implemented).
  388.  
  389.      #!/bin/sh
  390.      cat
  391.      # use lpr -i -l to print raw without trailing formfeed
  392.      if [ "$1" != -c -o "$4" = -i0 ]; then
  393.        # the ``echo -ne'' assumes that /bin/sh is really bash
  394.        echo -ne \\f
  395.      fi
  396.  
  397. 3.14 Printing with lpd to a serial port
  398. =======================================
  399.  
  400.    The first if lpd complains about "ioctl(TIOCEXCL)" being
  401. unimplemented you need a version of lpd that doesn't care (eg.
  402. lpd-590p2)
  403.  
  404.    There are two sets of flags which you will need to set, plus the baud
  405. rate (Note: the `fc' flag setting seems to override the `br#'
  406. capability, so be sure to set that correctly as well as the `br#'!).
  407.  
  408.    Each of the flags can have bits set and cleared. Clearing is done
  409. first, so specify the clear flags (`fc#' and `xc#') before the set
  410. flags (`fs' and `xs').
  411.  
  412.    Setting the `br#' capability is self-explanatory. Example: `br#9600'
  413.  
  414.    It is very easy to translate from `stty' settings to printcap flag
  415. settings. If you need to, see the man page for stty now.
  416.  
  417.    Use stty to set up the printer port so that you can cat a file to it
  418. and have it print correctly. Here's what `stty -a' looks like for my
  419. printer port:
  420.  
  421.      dina:/usr/users/andy/work/lpd/lpd# stty -a < /dev/ttyS2
  422.      speed 9600 baud; rows 0; columns 0; line = 0;
  423.      intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
  424.      eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
  425.      lnext = ^V; min = 1; time = 0;
  426.      -parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
  427.      -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr
  428.      -igncr -icrnl ixon -ixoff -iuclc -ixany -imaxbel
  429.      -opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0
  430.      bs0 vt0 ff0
  431.      -isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop
  432.      -echoprt -echoctl -echoke
  433.  
  434.    The only changes between this and the way the port is initialized at
  435. bootup are `-clocal', `-crtscts', and `ixon'. Your port may well be
  436. different depending on how your printer does flow control.
  437.  
  438.    Once you have your stty settings right, so that `cat file >
  439. /dev/ttyS2' (in my case) sends the file to the printer, look at the file
  440. `/usr/src/linux/include/linux/termios.h'. This contains a lot of
  441. `#define's and a few structs (You may wish to cat this file to the
  442. printer (you do have that working, right?) and use it as scratch paper
  443. - I (Andrew Tefft <teffta@engr.dnet.ge.com> did!). Go to the section
  444. that starts out
  445.  
  446.      /* c_cflag bit meaning */
  447.      #define CBAUD   0000017
  448.  
  449.    This section lists the meaning of the `fc#' and `fs#' bits.  You
  450. will notice that the names there (after the baud rates) match up with
  451. one of the lines of stty output. Didn't I say this was going to be easy?
  452.  
  453.    Note which of those settings are preceded with a - in your stty
  454. output. Sum up all those numbers (they are octal). This represents the
  455. bits you want to *clear*, so the result is your `fc#' capability.  Of
  456. course, remember that you will be setting bits directly after you
  457. clear, so you can just use `fc#0177777' (I do).
  458.  
  459.    Now do the same for those settings (listed in this section) which do
  460. not have a - before them in your stty output. In my example the
  461. important ones are CS8 (0000060), HUPCL (0002000), and CREAD (0000200).
  462. Also note the flags for your baud rate - mine is 0000015. Add those all
  463. up, and in my example you get 0002275. This goes in your `fs#'
  464. capability (`fs#02275' works fine in my example).
  465.  
  466.    Do the same with set and clear for the next section of the include
  467. file, "c_lflag bits". In my case I didn't have to set anything, so I
  468. just use `xc#0157777' and `xs#0'.
  469.  
  470.    Once your printcap is set up, try it out. If things don't work, see
  471. the next section.
  472.  
  473. 3.15 cat works to the serial port, but not lpd (1)
  474. ==================================================
  475.  
  476.    Generally getting lpd up and running is explained elsewhere, but if
  477. you are having trouble with serial port settings you can prevent `lpd'
  478. from trying to configure your port by treating you printer as one that
  479. does not present a normal device interface. See Also: Printers not in
  480. /dev.
  481.  
  482.   1. Set your printer (in your printcap) to `/dev/null1'. (`mknod
  483.      /dev/null1 c 1 3' because you don't want `/dev/null' to be opened
  484.      exclusively).
  485.  
  486.      remove the baud rate and flags settings from your printcap.
  487.  
  488.   2. Create a script such as this:
  489.  
  490.           #!/bin/sh
  491.           echo if: $* >> /var/spool/lpd/results
  492.           # /dev/lp is linked to /dev/ttyS2 which has the printer
  493.           exec your-old-input-filter $* > /dev/lp
  494.         ...or if you didn't have an old `if' installed...
  495.           #!/bin/sh
  496.           echo if: $* >> /var/spool/lpd/results
  497.           cat > /dev/lp
  498.           # the ``echo -ne'' assumes that /bin/sh is realy bash
  499.           echo -en \\f > /dev/lp
  500.  
  501.      Make sure it's world-executable and world-readable. Try out your
  502.      script (`/usr/lib/lpd/if < SOMEFILE') and see if it prints.
  503.  
  504.   3. Set the `if' capability in your printcap to call this script, e.g.
  505.      `if=/usr/lib/lpd/if'
  506.  
  507.   4. Use stty to correctly set your port settings. Try to print now.
  508.      You should be able to tell if things are being spooled, and things
  509.      *should* be printed, if your manual testing of the `if' script
  510.      works. But this is a kludge, so the idea is not to use the `if'
  511.      script.
  512.  
  513.    Assuming the above method using the `if' filter works and that you
  514. believe that you have specified what you think are the correct flags
  515. and baud rate in printcap; check `stty -a < /dev/ttyS2' (or whatever
  516. your printer port is).  If the settings are not correct, check your
  517. flags against your printout from termios.h. If the settings are *way*
  518. not correct, you may need a fixed lpd. The patch follows, and you can
  519. probably see why it's needed :-) Note: this patch is reversed and has
  520. already been applied (uh... unapplied :-) ) to lpd-590p2 so don't apply
  521. it if you already have that version or later.
  522.  
  523.    (the patch is coming in just a sec)
  524.  
  525.    When I was setting mine up, I followed a sequence like this:
  526.  
  527.      lprm WHATEVER # (make sure queue is empty and lpd is running)
  528.      stty CORRECT SETTINGS < /dev/ttyS2
  529.      lpr SOMETHING SMALL
  530.      stty -a < /dev/ttyS2  # (often had to ctrl-c out of this one)
  531.      
  532.      twiddle with flags
  533.      
  534.      lprm WHATEVER # make sure queue is empty again...
  535.  
  536.    Here's the patch (I it's reversed so apply it with `-R' - or, in
  537. practice, by hand!):
  538.  
  539.      -------------------------------Cut Here-------------------------------------
  540.      *** lpd-590/lpd/printjob.c  Thu Jul  8 20:56:59 1993
  541.      --- lpd-590/lpd/printjob.c~ Sat Feb 27 09:07:01 1993
  542.      ***************
  543.      *** 1271,1277 ****
  544.              }
  545.        #ifdef LINUX
  546.              ttybuf.c_cflag &= ~FC;          /* not quite right! */
  547.      !       ttybuf.c_cflag |= FS;           /* not quite right! */
  548.        #else
  549.              ttybuf.sg_flags &= ~FC;
  550.              ttybuf.sg_flags |= FS;
  551.      --- 1271,1277 ----
  552.              }
  553.        #ifdef LINUX
  554.              ttybuf.c_cflag &= ~FC;          /* not quite right! */
  555.      !       ttybuf.c_cflag |= ~FS;          /* not quite right! */
  556.        #else
  557.              ttybuf.sg_flags &= ~FC;
  558.              ttybuf.sg_flags |= FS;
  559.      -------------------------------Cut Here-------------------------------------
  560.  
  561. 3.16 Printers that are not simple devices
  562. =========================================
  563.  
  564.    [Firstly I'll explain the subject.] The most common example is a
  565. printer that is connected via a network in some strange way.  For
  566. example consider a printer connected to a host with which you can only
  567. communicate via E-mail.
  568.  
  569.    To use such a printer through `lpr' the `lp' capability of the print
  570. queue should be directed to a `/dev/null' type device (e.g. `mknod
  571. /dev/null1 c 1 3') but not `/dev/null' itself as `lpd' opens the device
  572. exclusively. Each filter must must explicitly uuencode and mail its
  573. output.
  574.  
  575.    In more complex cases if you already have an `if' or `of' filter for
  576. a strangely connected printer then other filters can pass their output
  577. to/through this filter to avoid duplication of effort.  In this case
  578. the `if' filter should usually be called with the `-c' switch to
  579. minimise the further manipulations if performs.
  580.  
  581.    I've heard someone has had some success trying something like this
  582. with Novell NetWare and the free mail transfer agent "Charon".
  583.  
  584. 3.17 Generating burst or banner pages
  585. =====================================
  586.  
  587.    For a simple text printer (in particular not PostScript) and a
  588. simple text banner simply take `:sh:' out of the printcap record. If you
  589. want to prevent the banner comming out in whatever font was last used
  590. on the printer then define the `tr' "capability" to be your printer's
  591. font reset command.
  592.  
  593.    If you want a fancy customised banner (or have a PostScript printer)
  594. leave `:sh:' in the printcap and make each of your filters print the
  595. banner. All the information to put on the banner is included in the
  596. filter's positional parameters.  RTFM(printcap) for details. [ If
  597. you're using <B.A.McCauley@bham.ac.uk>'s magic-filter package then call
  598. the code to print the banners from the config script. ]
  599.  
  600. 3.18 Spooling text to a PostScript printer
  601. ==========================================
  602.  
  603.    You need a filter based on a program that converts ascii to
  604. PostScript. The most well known of these is `enscript' but it's also
  605. the hardest to find (being non-free). Others include `a2ps',
  606. `nenscript', and `mpage'. See Also: Printing text via PostScript.
  607.  
  608. 3.19 Why graphics files are sometines truncated
  609. ===============================================
  610.  
  611.    This is usually because you've got a limit set on the maximum size
  612. file that can sit in the spool queue. Put `mx#0' in your printcap.
  613.  
  614. 3.20 Why `lpr -i' doesn't work
  615. ==============================
  616.  
  617.    To get `lpr -i' to work you need a filter installed as `if' that
  618. implements it.  The `-i' switch is simply passed on by `lpd' to the
  619. filter.  The filter called `lpf' that comes with `lpd' supports this
  620. feature but can only be used to print text.  If you whant to use this
  621. program but still want your filter to do some printer specific
  622. initialisation then write script thus:
  623.  
  624.      #!/bin/sh
  625.      # My initialisation stuff goes here
  626.      exec /usr/lib/lpf $*
  627.  
  628.    More reasonably you could have your filter script send the printer
  629. left margin sequence.
  630.  
  631.      #!/usr/bin/perl
  632.      # This example is in perl for a change because converting numbers
  633.      # to characters is tricky in shell script
  634.      
  635.      for ($i=0; !($_ = $ARGV[$i]) || !/^-i([0-9])+/; $i++) {}
  636.      
  637.      print pack("cAc",27,"l",$1);
  638.      
  639.      while (<STDIN>) { print; }
  640.  
  641. 3.21 Why `lpr -p' doesn't work?
  642. ===============================
  643.  
  644.    Because it's broken. `lpd' always thinks that the printer is 0
  645. characters wide regardless of what `/etc/printcap' or the `lpr'
  646. arguemnts say. The lpd-FAQ contained a patch but it has now been
  647. applied to lpd-590p1 and later. (Appologies to anyone who wanted this
  648. patch after the lpd-FAQ merged with printing-how.to. It was dropped in
  649. the mistaken belief that a new release of lpd-590 was iminent).
  650.  
  651.    One other thing: `lpd' calls `pr' by full pathname so if you keep
  652. `pr' somewhere different from `/usr/bin/pr' you will need a symlink.
  653. (Where `lpd' expects to find `pr' may vary from version to version).
  654.  
  655. 3.22 `lpc' and `lpq' warning of missing daemons
  656. ===============================================
  657.  
  658.    One `lpd' process runs all the time and it spawns children to handle
  659. each printer as needed. The health of the master daemon is not
  660. explicity reported by `lpc' but the absence of errors indicates that it
  661. is healthy. See Also: lpd not working. The `lpc stat' command will
  662. display the message "no daemon present" for each queue that is not
  663. actually printing at the time - this is completely normal. If printing
  664. has been disabled or the queue is empty then this is not an error
  665. condition. `lpq' is even more alarmist and will say "Warning: no daemon
  666. present". If the daemon is absent when the queue has entries and has
  667. not been explicitly stopped then this warning probably indicates an
  668. error in a filter. Fix the filter then use `lpd up QUEUE-NAME' to
  669. restart it.
  670.  
  671.    Sometimes when shutting down a printer `lpc' will get confused and
  672. try to kill a non existant daemon. This leads to irritating but harmless
  673. error messages. In lpd-590p2 these are much rarer.
  674.  
  675. 3.23 Using `lpr' over a network
  676. ===============================
  677.  
  678.    To print on the printer listed as `foo' in the printcap on machine
  679. `bar.baz.net' from the machine `mine.baz.net' you put an entry like
  680. this in your `/etc/printcap' (on `mine.baz.net'):
  681.  
  682.      foo:lp=:rm=bar.baz.net:rp=foo:sd=/usr/lpd/spool/foo:
  683.  
  684.    and, of course, create the spool directory `/usr/lpd/spool/foo'.
  685.  
  686.    There's no point specifying filters and the like in
  687. `mine.baz.net:/etc/printcap' as it's the ones in
  688. `bar.baz.net:/etc/printcap' that will get used.
  689.  
  690.    On the machine `bar.baz.foo', you need to put `mine.baz.net' on a
  691. line by itself in either `/etc/hosts.equiv' or `/etc/hosts.lpd'; note
  692. that putting it in `/etc/hosts.equiv' will allow for unauthenticated
  693. logins as well as printing.  `/etc/hosts.lpd' is for printing only.
  694.  
  695.    The machines listed in `/etc/hosts.*' should be described canonical
  696. names or numbers as lpd starts with the IP address and performs a
  697. revervse DNS lookup to get the name. If you are not sure of cannonical
  698. name you can just list all the names you know for a machine. (If you
  699. have `dig' then the command `dig -x A.B.C.D' can be used to get the
  700. canonical name of IP address A.B.C.D.)
  701.  
  702.    If the printer server is not nunning a BSD style spooler then it
  703. should still be possible to get it to work but the authority files may
  704. have a different names or formats. For example Chris Nystrom
  705. <chrisn@medianet.com> found that he had to create a file on the remote
  706. machine called `/usr/spool/lp/admins/lp/Systems' that listed his Linux
  707. box's name. We do not know if this is a SYSV thing or something
  708. exclusive to dynix/ptx 2.0.3 that he is using on his Sequent.
  709.  
  710.    If you can't get remote printing to work thrugh lpd you may be able
  711. to simply use remote command exectution like this:
  712.  
  713.      rsh bar.baz.net "lp -dlp" < FILE
  714.  
  715.    This example would be for a remote system using a SYSV type printing
  716. system on host `bar.baz.net'.
  717.  
  718. 3.24 Writing lpd filters
  719. ========================
  720.  
  721.    In normal Un*x terminology, filters are just programs (so they must
  722. have execute permission) that read a stream from their standard input
  723. and write to their standard output.
  724.  
  725.    lpd filters are filters in the sense that thay read STDIN and write
  726. to STDOUT, but are unusual in that they may assume that their standard
  727. input is a random acess file file and may perform lseek() operations on
  728. it.
  729.  
  730.    All lpd filters have a common command line syntax (or more often
  731. simply ignore command line parameters). For details of the command line
  732. parameters RTFM(printcap).
  733.  
  734.    If you want to write a shell script filter it must have a #!/bin/sh
  735. (or perl or csh) header.  Here is the generic form of a filter to
  736. accept PostScript.
  737.  
  738.      #!/bin/sh
  739.      /PATH.../gs -q -dSAFER -dNOPAUSE -r??? -sDevice=?????? -sOutputFile=- -
  740.  
  741.    Place the full pathname of the script as one of the filters (but not
  742. `of'!) parameter in the printcap for your printer.  I suggest putting
  743. such scripts in `/usr/lib/lpd/'. It is also usual to keep filters in
  744. the spool directories but this goes against normal practice of keeping
  745. programs and data neatly apart.  (`-dSAFER' attempts to protect against
  746. PostScript interpreter security holes, `-q' and `-dNOPAUSE' make it run
  747. nonstop, and Device is the appropriate special file for your printer).
  748.  
  749.    Here is an Epson FX-80 dvi filter using ghostscript:
  750.  
  751.      #!/bin/sh
  752.      /usr/TeX/bin/dvips -f | \
  753.                    /usr/bin/gs -q -dSAFER -sDEVICE=eps9high -r120x216 \
  754.                    -dNOPAUSE -sOutputFile=- -
  755.  
  756.    More tools useful for making filters are described elsewhere in this
  757. document.
  758.  
  759. 3.25 Debuging lpd filters
  760. =========================
  761.  
  762.    It's easier to debug filters if you test them in an immediate shell
  763. before you install them. (If your filter makes use of its command line
  764. arguments you'll have to specify them too).  `my-new-filter <FILE
  765. >/dev/lp1'
  766.  
  767.    A trick most people find useful when testing filters that make use of
  768. their command line arguments is to include `echo $* >>/tmp/filter-log'
  769. near the top of the script.
  770.  
  771.    If the filter works when you test it but still doesn't work when
  772. called by `lpd' then you may have forgotten the `#!/bin/sh' header. You
  773. may also need to set PATH within the script since the daemon's PATH may
  774. not have everything you need. Note also that the filter is run with
  775. uid=daemon so any programs it calls sould be world executable.
  776.  
  777. 3.26 Output (`of') filters
  778. ==========================
  779.  
  780.    Never use these. (Well strictly speaking there are circumstances but
  781. you're unlikey to meet them). Recently (early '94) there has been a
  782. spate of preople on c.o.l.help advokating the use of output filters.
  783. Using `of' filters means that if a printout is queued while another is
  784. already printing the 2 will be run together with a form-feed between.
  785. Any printer initialisation or file type detection will therfore not be
  786. performed for the second file and it will probably be printed
  787. incorrectly. There are other more subtle ways in which output filters
  788. can do unexpected things. IMHO: If using an output filter is the
  789. answer, it was probably a silly question.
  790.  
  791. This is Info file Printing-HOWTO.info, produced by Makeinfo-1.55 from
  792. the input file printing.texinfo.
  793.  
  794.    A guide to printing and previewing files under the Linux operating
  795. system.
  796.  
  797.    Copyright (C) 1994 by Grant Taylor and Brian McCauley
  798.  
  799. 3.27 Getting filters for given printers
  800. =======================================
  801.  
  802.    From: B.A.McCauley@bham.ac.uk (Brian McCauley)
  803.  
  804.    Because writing a filter usually takes about 10 minutes once you've
  805. found the right program (`gs', `dvilj' etc.) there's little call for
  806. ftp archives of printer filters but we are thinking of creating an
  807. extensive example file to go with this document.
  808.  
  809.    If you already have a program to print, say, DVI on your printer by
  810. some mechanism then making it into a filter is usually a matter of
  811. writting trivial shell script See Also: Writing lpd filters. If the
  812. program you are using insists on reading a names file as input see the
  813. next question. Text mode filters are trivial too (see this HOWTO)
  814. unless you want lpr to have a choice of fonts in which case they are
  815. slightly harder than trivial.  You will probably want to insert and
  816. `echo -ne' command at the beginning and end of your filter to set up
  817. the font etc to your liking.
  818.  
  819. 3.28 Filters from programs that won't read STDIN
  820. ================================================
  821.  
  822.    Some of the programs that are used in writing `lpd' filters are not
  823. capable of taking their input from their standard input. For example
  824. `dvilj2p' insists on a named file as its input (and what's more expects
  825. one with a `.dvi' suffix) so do this:
  826.  
  827.      #!/bin/sh
  828.      ln -s /proc/self/fd/0 /tmp/$$.dvi
  829.      dvilj2p /tmp/$$
  830.      rm /tmp/$$.dvi
  831.  
  832.    Note: If it wasn't for the fact that `dvilj2p' adds a `.dvi' suffix
  833. you wouldn't need the temporary symlink and could just specify
  834. `/proc/self/fd/0' directly. People who use this trick often usually
  835. permanently `ln -s /proc/self/fd/0 /dev/stdin'. If you're highly
  836. security concious and don't allow access to `/proc' you'll need to
  837. create a temporary file.
  838.  
  839. 3.29 Having many filters
  840. ========================
  841.  
  842.    Historically the `lpr' command was created to support a finite set
  843. of possible file types. You can, in fact, use any of the filters for any
  844. reason. If you're never going to use Benson Varian raster files you
  845. could use the `-v' switch for GIF files. You could even use `-d' for
  846. low res and `-v' for high res. Remember that if you create a filter for
  847. a file format that takes a long time to process then your printer may
  848. sit idle between print jobs even when there are things in the queue.
  849.  
  850.    If you are on a network remember that the filter setups go on the
  851. print server.  One way to avoid running out of filter options is to
  852. define several logical printers in `/etc/printcap' that all point to the
  853. same physical one and put each filter in the `if' field of a different
  854. printcap entry. This has the advantage that you can set the `PRINTER'
  855. enviroment variable to choose your filter rather than having to specify
  856. it on the command line each time. One small problem with this is that
  857. you have no control over the order in which files from separate queues
  858. are printed.
  859.  
  860.    Another (and these days more common) way to avoid running out of
  861. possible types is to use magic filters.
  862.  
  863. 3.30 Magic Filters
  864. ==================
  865.  
  866.    Magic filters deduce their input files' types from `magic numbers'
  867. (distictive byte patterns at particular offsets).  Magic filters are
  868. usually perl scripts, shell scripts or C programs that simply identify
  869. the file type then call the appropriate non-magic filter. Blatent plug
  870. :-) Brian has a generic magic filter bash script that selects the right
  871. filter to use based on the output of the `file' command. With a
  872. suitable magic filter (and 3 associated non-magic filters) you can do
  873. things like:
  874.  
  875.      lpr -d file1.dvi file2.div.Z file3.ps file4.texinfo.gz
  876.  
  877.    (BTW confguring `lpr' to handle texinfo files is getting a bit
  878. silly).
  879.  
  880.    This is now on the mailserver or at:
  881. `tsx-11.mit.edu:pub/linux/sources/usr.bin/magic-filter-0.4.tar.gz'
  882. (Although the release number will possibly change in future).
  883.  
  884.    `apsfilter' is a rather easier to use shell script that requires no
  885. additional filters and which is pre-configured for HP compatible laser
  886. printers. This is also available on the mailserver.
  887.  
  888.    An example written in C, which may be easily adapted to most
  889. installations is available from the printing mail server as `lpr_if.c'.
  890.  
  891.    Magic filters should never specified as `of' as the output filter
  892. only gets called once if a number of files are printed without a gap.
  893. There are other more subtle problems too using `of'.
  894.  
  895.    IMHO (Brian) magic filters as `if' are inelegant as they may prevent
  896. you, say, listing a PostScript or nroff file. (Most people disagree
  897. with me on this point.)
  898.  
  899. 3.31 Magic Filter Examples
  900. ==========================
  901.  
  902.    The following is an example of a magic shell script which should take
  903. either PostScript or text and deal with it:
  904.  
  905.      #!/bin/sh
  906.      # This is based on a script I received from Scott Doty and which was
  907.      # written by Keith Walker.  Keith's script made use of the fact that
  908.      # lpd passes options to if:
  909.      #
  910.      #  <if> -w<width> -l<length> -i<indent> -n <user> -h <host> <accountingfile>
  911.      #
  912.      # to print text out well at any size.  This one does not.  These options
  913.      # are also handy if you want to do your own snazzy header page, much
  914.      # like NeWSPrint from Sun does (although running PostScript through
  915.      # the display server to get it interpreted is a bit much :)
  916.      #
  917.      #
  918.      # gs will reset the printer anyway, so the this text setup doesn't matter.
  919.      # setup should include the escape code for \n conversion, if applicable.
  920.      #
  921.      printf "<printer setup for text printing (escape codes, etc)>"
  922.      
  923.      read first_line
  924.      first_two_chars=`expr $first_line : '\(..\)'`
  925.      
  926.      if [ "$first_two_chars" = "%!" ]; then # it's PostScript
  927.      
  928.              /usr/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=??????? -sOutputFile=- -
  929.      
  930.      else # it's plain text
  931.      
  932.              echo -n $first_line
  933.              cat
  934.              printf "\014"
  935.      
  936.      fi
  937.  
  938.    Note that for the paranoid, shell scripts run as someone other than
  939. the user are sometimes a security hole, but this is not the case with
  940. lpd filters as the script's environment is not under the control of the
  941. potential cracker.
  942.  
  943. 4 Previewing
  944. ************
  945.  
  946.    These sections describe various ways to preview things under Linux -
  947. that is, how to view them in a way approximating their final form
  948. without printing them out.
  949.  
  950. 4.1 ghostview
  951. =============
  952.  
  953.    Ghostview, a companion program for `gs', previews PostScript on an X
  954. display.  It also lets you select individual or ranges of pages from a
  955. PostScript document to print using `lpr'.  The new version, 1.5, has
  956. fixed a few glitches which never bothered me but may make a difference
  957. to you.  It also calls `gs' with the `-dSAFER' option and has a few
  958. more resource and command-line options relative to 1.4.1.  The real
  959. installation is from:
  960. `prep.ai.mit.edu:/pub/gnu/ghostview-XXX.tar.gz'
  961.  
  962.    It builds out of the box.  Ghostview requires `gs' to work.  The new
  963. version of `gs', 2.6.x, will use X display fonts in an effort to
  964. improve legibility at the low resolutions of a video monitor (a
  965. previous failing of this pair relative to commercial display-PostScript
  966. based systems).  This works very well for me at least, at the expense
  967. of exact character positioning (X fonts have different widths).  In
  968. fact, I thought that Ghostview looks better than Sun's pageview the
  969. other day when I looked at the same page in oth programs side-by-side.
  970. Ghostview/Ghostscript also has much more intelligent color handling
  971. than pageview.  You might wish to let `gs' render some Type 1 fonts you
  972. install instead of using platform fonts (or the awful fonts `gs' comes
  973. with.  To do this while in Ghostview (or in any situation involving the
  974. X11 driver), place `ghostscript.useExternalFonts: false' in your
  975. `.Xdefaults' file, and the platform fonts will not be used.
  976.  
  977.    This is part of a message posted to gnu.ghostscript.bug by Tim
  978. Theisen <ghostview@cs.wisc.edu>:
  979.      (note that the usual Linux X-server, XFree, is simply an enhanced
  980.      version of MIT's effort at an i386 X-server (X386), and does
  981.      contain the X11R5 Type 1 rasterizer which I beleive was
  982.      contributed by IBM.)
  983.  
  984.      Ghostscript now uses the X Toolkit to pick up X Resources.  Now
  985.      ghostscript uses the standard X rules that allow more specific
  986.      resources to override less specific ones giving users the full
  987.      power of X resources to control the X11 driver.  It also allows
  988.      system administrators to establish an application defaults file
  989.      with resources specific to their ghostscript installation.
  990.  
  991.      The customization choices mentioned in make.doc have been moved
  992.      into X resources and are now configured at run time rather than
  993.      compile time.  Sorry, this section of make.doc did not get revised
  994.      for the 2.6.1 release.
  995.  
  996.      If `useBackingPixmap' is set, ghostscript will attempt to allocate
  997.      a backing pixmap.  If one cannot be allocated, ghostscript will
  998.      issue a warning and ask for backing store instead.  (Since there
  999.      were insufficient resources for a backing pixmap, the X server may
  1000.      not provide backing store either.)
  1001.  
  1002.      Color Handling was totally revamped for gs 2.6.
  1003.  
  1004.      Ghostscript first checks for a suitable standard colormap.  If you
  1005.      have static colormap in your X server, it would be best to store a
  1006.      standard colormap property on the root window describing the color
  1007.      layout.  Ghostscript will then be able to take full advantage of
  1008.      the device.  If you have a standard colormap installed,
  1009.      ghostscript will start slightly faster since it does not have to
  1010.      allocate colors for a cube or ramp.
  1011.  
  1012.      If no standard colormap is available, ghostscript will allocate an
  1013.      RGB cube or gray ramp.  Ghostscript tries for a 5x5x5 cube on a
  1014.      color device, and a 128 gray ramp on grayscale devices.  It will
  1015.      never ask for more than 1/2 of the colors for a RGB cube or gray
  1016.      ramp.  It also takes into account the number of significant bits
  1017.      per pixel.  (i.e.  It won't ask for 128 gray levels if you only
  1018.      have 16 available.)
  1019.  
  1020.      Ghostscript will attempt to allocate colors that are off the color
  1021.      cube/ramp as the picture is being rendered.  Ghostscript will keep
  1022.      track of 256 dynamic colors.  After all these are allocated,
  1023.      ghostscript asks the X server directly.
  1024.  
  1025.      The foreground and background color can be set explicitly.  This
  1026.      is important for the visually impaired and when using the ghostview
  1027.      widget.
  1028.  
  1029.      Color Resources:
  1030.  
  1031.        1. `palette'(`Palette'): Default value: `Color'.  Other
  1032.           allowable settings: `Grayscale', `Monochrome'.  The palette
  1033.           resource is used to restrict the palette used for display.
  1034.           One can set palette to `Grayscale' or `Monochrome' to see how
  1035.           a file would be rendered in grayscale or monochrome on a
  1036.           color display.  I use it to avoid dithering of gray- scale
  1037.           figures on a color display with 4-bit DACs.
  1038.  
  1039.        2. `maxGrayRamp'(`MaxGrayRamp'): Default value: 128.  Maximum
  1040.           number of gray levels that ghostscript will attempt to
  1041.           allocate.  (It won't try for more than this on an 8-bit
  1042.           pseudo color display even if you set it higher.)  Set this
  1043.           lower if you want a smaller ramp and would prefer ghostscript
  1044.           to use dynamic colors.
  1045.  
  1046.        3. `maxRGBCube'(`MaxRGBCube'): Default value: 5.  Maximum number
  1047.           of colors levels that ghostscript will attempt to allocate.
  1048.           (It won't try for more than this on an 8-bit pseudo color
  1049.           display even if you set it higher.)  Set this lower if you
  1050.           want a smaller ramp and would prefer ghostscript to use
  1051.           dynamic colors.
  1052.  
  1053.      I believe these values to be a good compromise between dynamic
  1054.      allocation and fall back onto a fairly good color cube for
  1055.      dithering.
  1056.  
  1057.      You can use the foreground and background colors to accomplish
  1058.      "reverse video".  However, if you have a grayscale device, it may
  1059.      be better to reverse the gray ramp using the following PostScript
  1060.      code fragment:
  1061.  
  1062.           [{1 exch sub} /exec load currenttransfer /exec load] cvx settransfer
  1063.  
  1064.      The X11 driver now supports native X11 fonts.  If you have
  1065.      installed the HP XLFD font extensions into your font or X server.
  1066.      Ghostscript will also be able to use platform fonts at rotations
  1067.      of 90 degrees, with mirroring, and anamorphic scaling.
  1068.  
  1069.      The X11 driver does most if its work silently.  You can get it to
  1070.      report when it is using an X11 font by setting the logExternalFonts
  1071.      boolean in your X resources.
  1072.  
  1073.      The X11 driver is setup to use the standard fonts distributed with
  1074.      X11R5.  We purchased the Adobe Type Manager and the Adobe Plus
  1075.      Pack.  These font packages give all the fonts normally found in
  1076.      the Apple LaserWriter Plus.  The X11 driver is setup to handle
  1077.      these fonts as well.  (They are a superset of the bitmap fonts
  1078.      distributed with X11.)
  1079.  
  1080.      You may set the regularFonts, symbolFonts, or dinbatFonts resources
  1081.      if you have different fonts available.  Each font name must have 7
  1082.      dashes or it will be ignored.  Minimize the use of wildcards to
  1083.      promote faster matching.  (I once encountered an X server that took
  1084.      many seconds to do a font lookup when wildcards were carelessly
  1085.      used.)
  1086.  
  1087.      There is a different list of fonts for each common encoding.
  1088.      Regular fonts may be accessed in standard or ISO Latin 1 encoding.
  1089.      The bdf files that are distributed with X11 are in the ISO Latin
  1090.      1 encoding.  This leaves out the ligatures.  Luckily, the
  1091.      ligatures are present in the bdf files, but are not given an
  1092.      encoding, essentially commenting them out.  You can use the
  1093.      `fixfont' program from the xproof distribution
  1094.      (`Ftp.Cs.Wisc.Edu:/Pub/X/Xproof.Tar.Z', or
  1095.      `Ftp.X.Org:/Contrib/Xproof.Tar.Z') to reencode the bdf files and
  1096.      build X11 fonts that contain the ligatures (i.e standard encoding).
  1097.  
  1098.      If you have the Type1 fonts mentioned above, and you installed the
  1099.      Type1 rasterizer into you font or X server, you can use the
  1100.      appended fonts.scale to name your fonts so that ghostscript can
  1101.      find them.
  1102.  
  1103.      Font resources:
  1104.  
  1105.        1. `useExternalFonts'(`UseExternalFonts'): Default value: true.
  1106.           This resource controls whether X11 fonts will be used.
  1107.  
  1108.        2. `useScalableFonts'(`UseScalableFonts'): Default value: true.
  1109.           This resource controls whether scalable fonts will be used.
  1110.           If you have an outline scaler in your X server, you should
  1111.           have this on.  If you have an X terminal, you may get
  1112.           slightly better performance with this on.  If you have to use
  1113.           the X11 bitmap scaler, turn this off.  Fonts scaled by the
  1114.           bitmap scaler look worse than the default ghostscript fonts.
  1115.  
  1116.        3. `logExternalFonts'(`LogExternalFonts'): Default value: false.
  1117.           Controls whether to report when X11 fonts are being used.
  1118.  
  1119.      The following fonts.scale makes all of the fonts of the Adobe Type
  1120.      Manager and Adobe Plus pack available in standard and ISO Latin 1
  1121.      encoding.  (We were able to purchase the above two packages at an
  1122.      educational discount price of $150.)
  1123.  
  1124. 70
  1125. agw_____.pfb -Adobe-ITC Avant Garde Gothic-Book-r-normal--0-0-0-0-p-0-iso8859-1
  1126. agwo____.pfb -Adobe-ITC Avant Garde Gothic-Book-o-normal--0-0-0-0-p-0-iso8859-1
  1127. agd_____.pfb -Adobe-ITC Avant Garde Gothic-Demi-r-normal--0-0-0-0-p-0-iso8859-1
  1128. agdo____.pfb -Adobe-ITC Avant Garde Gothic-Demi-o-normal--0-0-0-0-p-0-iso8859-1
  1129. bkl_____.pfb -Adobe-ITC Bookman-Light-r-normal--0-0-0-0-p-0-iso8859-1
  1130. bkli____.pfb -Adobe-ITC Bookman-Light-i-normal--0-0-0-0-p-0-iso8859-1
  1131. bkd_____.pfb -Adobe-ITC Bookman-Demi-r-normal--0-0-0-0-p-0-iso8859-1
  1132. bkdi____.pfb -Adobe-ITC Bookman-Demi-i-normal--0-0-0-0-p-0-iso8859-1
  1133. com_____.pfb -Adobe-Courier-Medium-r-normal--0-0-0-0-m-0-iso8859-1
  1134. coo_____.pfb -Adobe-Courier-Medium-o-normal--0-0-0-0-m-0-iso8859-1
  1135. cob_____.pfb -Adobe-Courier-Bold-r-normal--0-0-0-0-m-0-iso8859-1
  1136. cobo____.pfb -Adobe-Courier-Bold-o-normal--0-0-0-0-m-0-iso8859-1
  1137. hv______.pfb -Adobe-Helvetica-Medium-r-normal--0-0-0-0-p-0-iso8859-1
  1138. hvo_____.pfb -Adobe-Helvetica-Medium-o-normal--0-0-0-0-p-0-iso8859-1
  1139. hvb_____.pfb -Adobe-Helvetica-Bold-r-normal--0-0-0-0-p-0-iso8859-1
  1140. hvbo____.pfb -Adobe-Helvetica-Bold-o-normal--0-0-0-0-p-0-iso8859-1
  1141. hvn_____.pfb -Adobe-Helvetica-Medium-r-Narrow--0-0-0-0-p-0-iso8859-1
  1142. hvno____.pfb -Adobe-Helvetica-Medium-o-Narrow--0-0-0-0-p-0-iso8859-1
  1143. hvnb____.pfb -Adobe-Helvetica-Bold-r-Narrow--0-0-0-0-p-0-iso8859-1
  1144. hvnbo___.pfb -Adobe-Helvetica-Bold-o-Narrow--0-0-0-0-p-0-iso8859-1
  1145. ncr_____.pfb -Adobe-New Century Schoolbook-Medium-r-normal--0-0-0-0-p-0-iso8859-1
  1146. nci_____.pfb -Adobe-New Century Schoolbook-Medium-i-normal--0-0-0-0-p-0-iso8859-1
  1147. ncb_____.pfb -Adobe-New Century Schoolbook-Bold-r-normal--0-0-0-0-p-0-iso8859-1
  1148. ncbi____.pfb -Adobe-New Century Schoolbook-Bold-i-normal--0-0-0-0-p-0-iso8859-1
  1149. por_____.pfb -Adobe-Palatino-Medium-r-normal--0-0-0-0-p-0-iso8859-1
  1150. poi_____.pfb -Adobe-Palatino-Medium-i-normal--0-0-0-0-p-0-iso8859-1
  1151. pob_____.pfb -Adobe-Palatino-Bold-r-normal--0-0-0-0-p-0-iso8859-1
  1152. pobi____.pfb -Adobe-Palatino-Bold-i-normal--0-0-0-0-p-0-iso8859-1
  1153. sy______.pfb -Adobe-Symbol-Medium-r-normal--0-0-0-0-p-0-iso8859-1
  1154. tir_____.pfb -Adobe-Times-Medium-r-normal--0-0-0-0-p-0-iso8859-1
  1155. tii_____.pfb -Adobe-Times-Medium-i-normal--0-0-0-0-p-0-iso8859-1
  1156. tib_____.pfb -Adobe-Times-Bold-r-normal--0-0-0-0-p-0-iso8859-1
  1157. tibi____.pfb -Adobe-Times-Bold-i-normal--0-0-0-0-p-0-iso8859-1
  1158. zcmi____.pfb -Adobe-ITC Zapf Chancery-Medium-i-normal--0-0-0-0-p-0-iso8859-1
  1159. zd______.pfb -Adobe-ITC Zapf Dingbats-Medium-r-normal--0-0-0-0-p-0-iso8859-1
  1160. agw_____.pfb -Adobe-ITC Avant Garde Gothic-Book-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1161. agwo____.pfb -Adobe-ITC Avant Garde Gothic-Book-o-normal--0-0-0-0-p-0-adobe-fontspecific
  1162. agd_____.pfb -Adobe-ITC Avant Garde Gothic-Demi-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1163. agdo____.pfb -Adobe-ITC Avant Garde Gothic-Demi-o-normal--0-0-0-0-p-0-adobe-fontspecific
  1164. bkl_____.pfb -Adobe-ITC Bookman-Light-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1165. bkli____.pfb -Adobe-ITC Bookman-Light-i-normal--0-0-0-0-p-0-adobe-fontspecific
  1166. bkd_____.pfb -Adobe-ITC Bookman-Demi-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1167. bkdi____.pfb -Adobe-ITC Bookman-Demi-i-normal--0-0-0-0-p-0-adobe-fontspecific
  1168. com_____.pfb -Adobe-Courier-Medium-r-normal--0-0-0-0-m-0-adobe-fontspecific
  1169. coo_____.pfb -Adobe-Courier-Medium-o-normal--0-0-0-0-m-0-adobe-fontspecific
  1170. cob_____.pfb -Adobe-Courier-Bold-r-normal--0-0-0-0-m-0-adobe-fontspecific
  1171. cobo____.pfb -Adobe-Courier-Bold-o-normal--0-0-0-0-m-0-adobe-fontspecific
  1172. hv______.pfb -Adobe-Helvetica-Medium-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1173. hvo_____.pfb -Adobe-Helvetica-Medium-o-normal--0-0-0-0-p-0-adobe-fontspecific
  1174. hvb_____.pfb -Adobe-Helvetica-Bold-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1175. hvbo____.pfb -Adobe-Helvetica-Bold-o-normal--0-0-0-0-p-0-adobe-fontspecific
  1176. hvn_____.pfb -Adobe-Helvetica-Medium-r-Narrow--0-0-0-0-p-0-adobe-fontspecific
  1177. hvno____.pfb -Adobe-Helvetica-Medium-o-Narrow--0-0-0-0-p-0-adobe-fontspecific
  1178. hvnb____.pfb -Adobe-Helvetica-Bold-r-Narrow--0-0-0-0-p-0-adobe-fontspecific
  1179. hvnbo___.pfb -Adobe-Helvetica-Bold-o-Narrow--0-0-0-0-p-0-adobe-fontspecific
  1180. ncr_____.pfb -Adobe-New Century Schoolbook-Medium-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1181. nci_____.pfb -Adobe-New Century Schoolbook-Medium-i-normal--0-0-0-0-p-0-adobe-fontspecific
  1182. ncb_____.pfb -Adobe-New Century Schoolbook-Bold-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1183. ncbi____.pfb -Adobe-New Century Schoolbook-Bold-i-normal--0-0-0-0-p-0-adobe-fontspecific
  1184. por_____.pfb -Adobe-Palatino-Medium-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1185. poi_____.pfb -Adobe-Palatino-Medium-i-normal--0-0-0-0-p-0-adobe-fontspecific
  1186. pob_____.pfb -Adobe-Palatino-Bold-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1187. pobi____.pfb -Adobe-Palatino-Bold-i-normal--0-0-0-0-p-0-adobe-fontspecific
  1188. sy______.pfb -Adobe-Symbol-Medium-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1189. tir_____.pfb -Adobe-Times-Medium-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1190. tii_____.pfb -Adobe-Times-Medium-i-normal--0-0-0-0-p-0-adobe-fontspecific
  1191. tib_____.pfb -Adobe-Times-Bold-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1192. tibi____.pfb -Adobe-Times-Bold-i-normal--0-0-0-0-p-0-adobe-fontspecific
  1193. zcmi____.pfb -Adobe-ITC Zapf Chancery-Medium-i-normal--0-0-0-0-p-0-adobe-fontspecific
  1194. zd______.pfb -Adobe-ITC Zapf Dingbats-Medium-r-normal--0-0-0-0-p-0-adobe-fontspecific
  1195.  
  1196. 4.2 gspreview
  1197. =============
  1198.  
  1199.    This is another front-end for Ghostscript.  I have gotten and built
  1200. it, and actually preferred the user interface, but it had a few bugs.
  1201. It didn't seem as full-featured as ghostview, though.  (Not that there
  1202. are all *that* many features in ghostview, but it does its job well).
  1203. `ftp.x.org:/contrib/gspreview...'
  1204.  
  1205. 4.3 xdvi
  1206. ========
  1207.  
  1208.    A beautifully legible previewing program for dvi with a handy
  1209. zoom+pan feature.  Will not interpret PostScript specials, which are
  1210. understood only by `dvips' (back to the compiler, object file, and now
  1211. linker analogy :-)  To view a file, do `xdvi file.dvi'.  This comes
  1212. with either TeX or X in most distributions.  Either way, you've
  1213. probably got one.  If not, look in `ftp.x.org:/contrib/'.
  1214.  
  1215. 4.4 xtex
  1216. ========
  1217.  
  1218.    Xtex is similar in purpose to xdvi.  I have tried to build it under
  1219. Linux and failed.  It is available as:
  1220. `ftp.x.org:/contrib/xtex-2.18.5.tar.z'
  1221.  
  1222. 4.5 gxditview
  1223. =============
  1224.  
  1225.    Ditview produces a preview version of `troff' source using X fonts.
  1226. `groff -TX100 -mandoc MAN PAGE' will run gxditview to show you a
  1227. typeset version of the man page.  `-TX75' is the same thing, but tiny.
  1228. Most distributions don't have a working one at all.  A good one comes
  1229. with the source to `groff', which you might want to get anyway for the
  1230. additional drivers (some distributions are missing some, including
  1231. PostScript).
  1232. `prep.ai.mit.edu:/pub/gnu/groff-XXXX.tar.z'
  1233.  
  1234. 4.6 non-X previewing
  1235. ====================
  1236.  
  1237.    Ghostscript comes with pc video hardware drivers, but under un*x
  1238. these are not a good thing.  However, there are `gs' binaries around
  1239. which will use the Linux VGA library (`svgalib').  The Ghostscript
  1240. device for this is called linux, thus `gs -sDEVICE=linux file.ps' will
  1241. show you an image of the PostScript.  The environment variable
  1242. `GSVGAMODE' is important for this.  Set it to the nuber of the video
  1243. mode you want, taken from the vga.h which comes with vgalib.
  1244.  
  1245.    If you need this driver, a patch to put in Linux svgalib is available
  1246. from the printing mail server or as:
  1247.      ws105.zfn.uni-bremen.de:/pub/gs261-linuxdriver.sh
  1248.      ws105.zfn.uni-bremen.de:/pub/gs261-svgalib.tar.gz
  1249.  
  1250.    Another possibly different svgalib patch is found in:
  1251. `ftp.cdrom.com:/pub/linux/misc'
  1252.  
  1253.    The plain vgalib driver is available on Sunsite.
  1254.  
  1255.    Texmgr is a program which will preview dvi under MGR.  I don't
  1256. beleive that it currently works under Linux MGR, but if it does, MGR
  1257. uses sufficiently less memory and disk that this might be an attractive
  1258. option for some.
  1259.  
  1260.    dvgt is a program which will preview dvi with Linux svgalib, or on
  1261. one of several types of graphics terminals including vt, tek, or a PC
  1262. with MS-Kermit.  It is available on sunsite.
  1263.  
  1264. 5 Ascii Translation
  1265. *******************
  1266.  
  1267.    These sections describe various programs which can generate plain
  1268. ascii from some file formats.
  1269.  
  1270. 5.1 from TeX
  1271. ============
  1272.  
  1273.    Lametex will generate ascii from TeX source.  It is available as:
  1274. `sunsite.unc.edu:/pub/Linux/apps/tex/lametex.tar.z'
  1275.  
  1276.    LaTeX is used by the Linux Doc Projext to generate text versions of
  1277. their manuals.  I don't know where to find it.
  1278.  
  1279. 5.2 from dvi
  1280. ============
  1281.  
  1282.    `dvi2tty' is a program which will process dvi into text.  Aparently,
  1283. it will also make an effort at reproducing graphics as well.  I do not
  1284. know where to find it.
  1285.  
  1286. 5.3 from PostScript
  1287. ===================
  1288.  
  1289.    Ghostscript 2.6.1 comes with a script file which will use `gs' to
  1290. extract just the text from a ps file, called `ps2ascii'.  (*note
  1291. PostScript., for information above for where it can be found).
  1292. Further documentation is in the Ghostscript 2.6.1 distribution files
  1293. `gs_2asc.ps' and `use.doc'
  1294.  
  1295. 5.4 from troff
  1296. ==============
  1297.  
  1298.      groff -Tascii or -Tlatin1 ...
  1299.  
  1300. 5.5 from ascii/latin1
  1301. =====================
  1302.  
  1303.    The GNU program `recode' handles conversion between various forms of
  1304. straight text encoding, ie from Latin-1 to ASCII.  This is available on
  1305. prep.ai.mit.edu.
  1306.  
  1307. --
  1308. Unless otherwise stated, Linux HOWTO documents are copyrighted by their
  1309. respective authors. Linux HOWTO documents may be reproduced and distributed 
  1310. in whole or in part, in any medium physical or electronic, without permission 
  1311. of the author. Translations and derivative works are similarly permitted 
  1312. without express permission. Commercial redistribution is allowed and 
  1313. encouraged; however, the author would like to be notified of any such 
  1314. distributions. 
  1315.  
  1316. In short, we wish to promote dissemination of this information through as
  1317. many channels as possible. However, we do wish to retain copyright on the
  1318. HOWTO documents, and would like to be notified of any plans to redistribute
  1319. the HOWTOs. If you have questions, please contact Matt Welsh, the Linux
  1320. HOWTO coordinator, at mdw@sunsite.unc.edu.
  1321.